<?php
	session_start();
	require_once("../config.php");
	include_once("../database/DataBase.php");
	
	$search_type = $_POST["search_type"];
	$keyword = $_POST["keyword"];
	
	$database = New DataBase();
	$database->open_connection();
	$result = $database->searchUserByLoginIDorEmail($search_type, $keyword, "", $_SESSION["user_type"]);
	
	if($result != null){
		echo "<table>";
		echo "<tr><td>Login ID</td><td>First Name</td><td>First Name</td><td>Email</td><td>Type</td><td>Last Login Date</td><td>Action</td></tr>";
		
		while ($row = mysql_fetch_assoc($result)) {
		echo "<tr><td>".$row["login_id"]."</td><td>".$row["firstname"]."</td><td>".$row["lastname"]."</td><td>".$row["email"]."</td><td>".$row["type_id"]."</td><td>".$row["last_login_date"]."</td><td>";
		
		echo "<a href=\"../include/match_user_process.php?key=".encrypt_string($row["login_id"])."\">Match User</a>";
		
		echo "</td></tr>";
		}
		
		echo "</table>";
	}
	else{
		echo "<p>No such user in system.</p>";
	}

	$database->close_connection();
?>